package EA;
import java.util.Hashtable;

/** This class can be used to evaluate TreeGenomes in a somewhat faster way 
    that using the TreeGenomes evaluate. It is useful if you want to plot 
    the value of the expression represented by a treegenome.
*/
public class NumTreeGenomeFastEval extends TreeGenomeFastEval
{

  public NumTreeGenomeFastEval()
    {
      sons = new NumTreeGenomeFastEval[0];
    }

  public NumTreeGenomeFastEval(NumTreeGenomeFastEval[] thesons)
    {
      super();
      sons = thesons;
    }

  /** Evaluate the expression. */
  public double evaluateNumerical()
    {
      return 0;
    }

  /** Evaluate the expression where some of the parts of the expression
      can be passed by putting them in the hashtable.
  */
  public double evaluateNumerical(Hashtable htable)
    {
      return 0;
    }

  /** Evaluate the sons and return an array containing the results. This 
      can be used when subclassing.
  */
  public double[] evaluateNumericalSons()
    {
      double[] res = new double[sons.length];

      for (int i=0;i<sons.length;i++) {
	res[i] = ((NumTreeGenomeFastEval)sons[i]).evaluateNumerical();
      }
      return res;
    }


  /** Evaluate the sons and return an array containing the results.
      You can pass the Hashtable so the sons are evaluated in that context.
      This can be used when subclassing.
  */
  public double[] evaluateNumericalSons(Hashtable htable)
    {
      double[] res = new double[sons.length];

      for (int i=0;i<sons.length;i++) {
	res[i] = ((NumTreeGenomeFastEval)sons[i]).evaluateNumerical(htable);
      }
      return res;
    }

}

